﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cherry.Agile.Configuration
{
    public static class AgileConfiguration
    {
        static ConfigManager __inner = null;

        /// <summary>
        /// 初始化配置
        /// </summary>
        /// <param name="config"><see cref="ConfigManager"/></param>
        public static void Setup(ConfigManager config)
        {
            __inner = config;
        }

        /// <summary>
        /// 初始化配置
        /// </summary>
        /// <param name="file">配置文件</param>
        public static void Setup(string file)
        {
            __inner = ConfigManager.Create(file, false);
        }

        const string SECTION_NAME = "agile";
        /// <summary>
        /// 
        /// </summary>
        public static AgileConfigSection Current
        {
            get
            {
                if (__inner == null)
                    return ConfigManager.GetSection<AgileConfigSection>(SECTION_NAME);
                else
                    return (AgileConfigSection)__inner.GetSection(SECTION_NAME);
            }
        }
    }
}
